package LeetCode.exercise;

import java.util.ArrayList;
import java.util.List;

public class LC784 {
    List<String> res = new ArrayList<>();
    StringBuilder sb = new StringBuilder();
    public List<String> letterCasePermutation(String s) {
        dfs(s, 0);
        return res;
    }
    public void dfs(String s, int cur){
        if(cur == s.length()){
            res.add(sb.toString());
            return;
        }
        char c = s.charAt(cur);
        if(c >= '0' && c <= '9'){
            sb.append(c);
            dfs(s, cur+1);
            sb.deleteCharAt(sb.length()-1);
        }
        if(c >= 'a' && c <= 'z'){
            sb.append(c);
            dfs(s, cur+1);
            sb.deleteCharAt(sb.length()-1);

            sb.append((char)(c-32));
            dfs(s, cur+1);
            sb.deleteCharAt(sb.length()-1);
        }
        if(c >= 'A' && c <= 'Z'){
            sb.append(c);
            dfs(s, cur+1);
            sb.deleteCharAt(sb.length()-1);

            sb.append((char)(c+32));
            dfs(s, cur+1);
            sb.deleteCharAt(sb.length()-1);
        }
    }

    public static void main(String[] args) {
        LC784 lc = new LC784();
        System.out.println(lc.letterCasePermutation("a1b2"));
    }
}
